<template>
  <slot></slot>
</template>
<script setup>
import { formKey } from '@/constants';
import { provide, reactive } from 'vue';

const state = reactive({
  errors: {}
});
provide(formKey, state);
const clearError = () => {
  if (state?.errors) {
    state.errors = {};
  }
};

const changeError = key => {
  if (state?.errors) {
    state.errors[key] = null;
  }
};
defineExpose({
  clearError,
  changeError
});
</script>
